package com.home.service;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;

import com.home.dao.UserDao;
import com.home.dao.UserDaoImpl;
import com.home.entity.User;
import com.home.exception.AbstractDaoException;

public class UserServiceImpl implements UserService{
    protected Logger log = Logger.getLogger(UserDaoImpl.class);
	private UserDao	userDao;
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
	/**
	 * 添加用户
	 * @param user
	 * @return
	 */
	public int addUser(User user){
          return userDao.addUser(user);
	}
	
	/**
	 * 查询用户
	 * @param username
	 * @param passsord
	 * @return
	 */
	public User findUserByNameAndPassword(String username,String passsord){
		return userDao.findUserByNameAndPassword(username, passsord);
	}
	
	/**
     * 通过邮箱 或者用户名登陆
     * @param user
     * @return
     * @throws DataAccessException
     */
    public User findUserByUser(User user){
        return userDao.findUserByUser(user);
    }
}
